﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NCT.MRS.DataAccessLayer.Entities;

namespace NCT.MRS.DataAccessLayer.Configurations
{
    public class UserConfiguration : EntityTypeConfiguration<User>
    {
        public UserConfiguration()
        {
            HasKey(P => P.Id);
            Property(P => P.FirstName).IsRequired().HasMaxLength(30);
            Property(P => P.LastName).IsRequired().HasMaxLength(30);
            Property(P => P.MiddleName).IsOptional().HasMaxLength(30);
            Property(P => P.Password).IsRequired().HasMaxLength(100);
            Property(P => P.Username).IsRequired().HasMaxLength(30);

            HasRequired(P => P.Role).WithMany(P => P.Users).HasForeignKey(P => P.RoleId);
        }
    }
}
